package lxq.away3d.primitives;

import away3d.containers.ObjectContainer3D;
import away3d.materials.MaterialBase;
import away3d.primitives.PlaneGeometry;
import away3d.textures.BitmapCubeTexture;

class SixBox extends ObjectContainer3D {
private var _posx:Plane;
private var _negx:Plane;
private var _posy:Plane;
private var _negy:Plane;
private var _posz:Plane;
private var _negz:Plane;

public function new(width:Float=100,height:Float=100,length:Float=100,material:BitmapCubeTexture=null) {
	super();
	var halfWidth:Float=width>>1;
	var halfHeight:Float=height>>1;
	var halfLength:Float=length>>1;
	trace(halfHeight,halfLength,halfWidth)
	_posx=new Plane(length,height);
	_posy=new Plane(width,length);
	_posz=new Plane(width,height);
	_negx=new Plane(length,height);
	_negy=new Plane(width,length);
	_negz=new Plane(width,height);
	addChildren(_posx,_posy,_posz,_negx,_negy,_negz);
	_posx.x=halfWidth;
	_negx.x=-halfWidth;
	
	_posy.y=halfHeight;
	_negy.y=-halfHeight;
	
	_posz.z=halfLength;
	_negz.z=-halfLength;
	
	_posx.rotationZ=-90;
	_negx.rotationZ=90;
	_posx.rotationY=90;
	_negx.rotationY=90;
	_posz.rotationX=90;
	_negz.rotationX=-90;
	_negy.rotationX=180;
}
public function setAllSurface(material:MaterialBase):Void{
	_posx.material=material;
	_posy.material=material;
	_posz.material=material;
	_negx.material=material;
	_negy.material=material;
	_negz.material=material;
}
public var negz(getNegz, setNegz):Plane;
 	private function getNegz():Plane {
	return _negz;
}

private function setNegz(value:Plane):Void {
	_negz=value;
}

public var posz(getPosz, setPosz):Plane;
 	private function getPosz():Plane {
	return _posz;
}

private function setPosz(value:Plane):Void {
	_posz=value;
}

public var negy(getNegy, setNegy):Plane;
 	private function getNegy():Plane {
	return _negy;
}

private function setNegy(value:Plane):Void {
	_negy=value;
}

public var posy(getPosy, setPosy):Plane;
 	private function getPosy():Plane {
	return _posy;
}

private function setPosy(value:Plane):Void {
	_posy=value;
}

public var negx(getNegx, setNegx):Plane;
 	private function getNegx():Plane {
	return _negx;
}

private function setNegx(value:Plane):Void {
	_negx=value;
}

public var posx(getPosx, setPosx):Plane;
 	private function getPosx():Plane {
	return _posx;
}

private function setPosx(value:Plane):Void {
	_posx=value;
}
public var doubleSide(null, setDoubleSide):Bool;
 	private function setDoubleSide(value:Bool):Void{
	var geom:PlaneGeometry=posx.geometry as PlaneGeometry;
	geom.doubleSided=value;
	geom=posy.geometry as PlaneGeometry;
	geom.doubleSided=value;
	geom=posz.geometry as PlaneGeometry;
	geom.doubleSided=value;
	geom=negx.geometry as PlaneGeometry;
	geom.doubleSided=value;
	geom=negy.geometry as PlaneGeometry;
	geom.doubleSided=value;
	geom=negz.geometry as PlaneGeometry;
	geom.doubleSided=value;
}

}